package Junit;

import domain.items.Item;
import domain.items.Topic;
import interfaces.DataRepository;
import persistence.jdbc.JDBCDataRepository;
import junit.framework.TestCase;

public class JDBCDataRepositoryTest extends TestCase {

	private DataRepository _dataRep;
	private Item _root;
	private Item _currentlyViewedItem;
	
	public JDBCDataRepositoryTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		super.setUp();
		this._dataRep = new JDBCDataRepository();
		this._root = this._dataRep.getRootTopic();
		this._currentlyViewedItem = _root;
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testGetRoot() {
		this._currentlyViewedItem = this._dataRep.getRootTopic();
		assertTrue(this._currentlyViewedItem != null);
		Topic rootTopic = (Topic)this._currentlyViewedItem;
		assertTrue(rootTopic.getFather() == rootTopic);
		assertTrue(rootTopic.getId() == 1);
		assertTrue(rootTopic.getSubItems().size() == 4);
		assertTrue(rootTopic.getSubItems().elementAt(0).getName().equals("Year 1"));
		assertTrue(rootTopic.getSubItems().elementAt(1).getName().equals("Year 2"));
		assertTrue(rootTopic.getSubItems().elementAt(2).getName().equals("Year 3"));
		assertTrue(rootTopic.getSubItems().elementAt(3).getName().equals("Year 4"));		
	}
	

	
	
	

	
}
